var _ = require('lodash');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var makeConfig = require("./base.config.js").makeConfig;
var baseConfig = require("./base.config.js").config;
var path = require('path');

var plugins = [];

const keys = _.keys(baseConfig.entry);

plugins.push(new HtmlWebpackPlugin({
  chunks: keys,
  filename:`index.html`,//分模块文件夹
  template: path.resolve(__dirname,"../template.html")
}));

plugins.push(new ExtractTextPlugin("[name].css"))
plugins.push(new webpack.optimize.UglifyJsPlugin());

var config = makeConfig({
  output: {
    path: path.resolve(__dirname,"../dist"),
    publicPath: '/',
    filename:'[name].js'
  },
  plugins: plugins
})

module.exports =  config
